package com.tao.design.adapter

/**
 *
 * @ProjectName:    lab
 * @Package:        com.tao.design.adapter
 * @ClassName:      adapter
 * @Description:     java类作用描述
 * @Author:         wangxf
 * @CreateDate:     2022/4/26 11:03
 * @UpdateUser:     更新者
 * @UpdateDate:     2022/4/26 11:03
 * @UpdateRemark:   更新说明
 * @Version:        1.0
 */
interface Duck {
    fun quack();
    fun fly();

}

class MallardDuck : Duck {
    override fun quack() {
    }

    override fun fly() {
    }
}

interface Turkey {
    fun gobble()
    fun fly();
}

class WildTurkey : Turkey {
    override fun gobble() {
    }

    override fun fly() {
    }
}


class Adapter(val turkey: Turkey) : Duck {
    override fun quack() {
        turkey.gobble()
    }

    override fun fly() {
        turkey.fly()
    }
}

fun main() {
    val adapter: Duck = Adapter(WildTurkey());
    testDuck(adapter);
}

private fun testDuck(duck: Duck) {
    duck.quack()
    duck.fly()
}